package org.act.BPEL2Automata.automata.module;

import java.util.LinkedList;

/**
 * 
 * a <b>LabelFunction</b> consists of a list of <b>LogicalFormula</b>s
 * (<b>SimpleLogicalFormulaImp</b> and <b>ComplexLogicalFormulaImp</b> are 
 * all based on <b>LogicalFormula</b>). 
 * @author baoxiwu<bb@feijiao.info>,ACT,Beihang University
 * @version 0.9.0
 * @since 2010-04-10
 * 
 */
public class LabelFunction {
	//a list of logical formulas.
	private LinkedList<LogicalFormula> LFList = new LinkedList<LogicalFormula>();
	
	
	public LabelFunction(){
	//empty
	}
	
	
	//setter and getter methods.
	public void setLogicalFormulaList(LinkedList<LogicalFormula> logicalFormulaList){
		this.LFList = logicalFormulaList;
	}
	
	public LinkedList<LogicalFormula> getLogicalFormulaList(){
		return this.LFList;
	}
	
	
	public void add(LogicalFormula logicalFormula){
		this.LFList.add(logicalFormula);
	}
	
	public void addAll(LinkedList<LogicalFormula> logicalFormulaList){
		this.LFList.addAll(logicalFormulaList);
	}
	
	public void remove(LogicalFormula logicalFormula){
		this.LFList.remove(logicalFormula);
	}
	
	
	//only one logical formula determined by one specified key.
	public LogicalFormula getByKey(State key){
		LogicalFormula lf = null;
		
		for(int i = 0; i < this.LFList.size(); i++){
			if(this.LFList.get(i).getKey() == key){
				lf= this.LFList.get(i);
			}
		}
		
		return lf;
	}
}
